<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../../../taglib.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<base href="<%=basePath%>" />
<%@ include file="/webmodules/console/css.jsp"%>
<%@ include file="/webmodules/console/js.jsp"%>
<easyui:add>
<script type="text/javascript">
$(function() {
	if($.isFunction(window.init_before)){
		init_before();
	}
	$('#myform').form({
		url : 'dragon/model/action/BizObjectHandler/add.ejw',
		onSubmit : function() {
			top.showProgress();
			var isValid = $(this).form('validate');
			if(window.before_submit){if(!before_submit()){isValid = false;}}
			if(!isValid){top.hideProgress();}
			return isValid;
		},
		success : function(data) {
			top.hideProgress();
			try{
				data = eval('(' + data + ')');
			}catch(e){
				top.showErrorMsg("出错了", data);
				return;
			}
			if(data.MESSAGE_ERROR != undefined && data.MESSAGE_ERROR != ''){
				top.showMsg("错误", data.MESSAGE_ERROR, true,'error');
			}else if(data.MESSAGE_WARNING != undefined && data.MESSAGE_WARNING != ''){
				top.showMsg("警告", data.MESSAGE_WARNING, true,'warning');
			}else{
				if(data.MESSAGE_INFO != undefined && data.MESSAGE_INFO != ''){
					top.showMsg("", data.MESSAGE_INFO, false);
				}else{
					top.showMsg("","添加成功！", false); 
				}
				top.getWindow('authorize').$('#mydatagrid').datagrid('reload');
				top.closeWindow('DefaultAdd');
			}
		}
	});
	
	$("body").mousedown(function(){
		validateMsg('USER_TID',false);
	});

});
function before_submit(){
	if(!validate("[{'id':'PROCESS','name':'PROCESS','type':'radio','msg':'请选择用户操作！'}]")){
		return false;
	}
	if($('#USERGROUP_TID').val().trim().length == 0 && $('#ORG_TID').val().trim().length == 0 && $('#USER_TID').val().trim().length == 0){
		validateMsg('USER_TID',true,'用户组，组织机构，用户至少选择一个！');
		return false;
	}
	return true;
}
</script>
</head>
<body>
${html}
</body>
</easyui:add>
</html>